package com.chinairi.mall.controller;


import com.chinairi.common.utils.ApplicationContextUtil;
import com.chinairi.common.utils.RedisUtil;
import com.chinairi.common.utils.ResponseUtil;
import com.chinairi.mall.dao.ProjectMapper;
import com.chinairi.mall.model.Collect;
import com.chinairi.mall.service.ICollectService;
import com.chinairi.mall.service.impl.ProjectServiceImpl;
import com.chinairi.mall.service.impl.SysUserServiceImpl;
import com.chinairi.mall.service.impl.UserCompanyInfoServiceImpl;
import com.chinairi.mall.service.modelobject.PurchaseToProjectRedisMO;
import com.chinairi.mall.service.modelobject.ShopInfoToCompRedisMO;
import com.chinairi.mall.service.modelobject.UserInfoToRedisMO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.chinairi.common.controller.BaseController;

import java.io.IOException;
import java.util.Map;

/**
 * <p>
 * 收藏夹表 前端控制器
 * </p>
 *
 * @author Webgasd
 * @since 2020-09-05
 */
@RestController
@RequestMapping("/collect")
public class CollectController extends BaseController {
    @Autowired
    private ICollectService iCollectService;

    /**
     * 新增收藏夹数据
     * @param collect
     * @throws IOException
     */
    @PostMapping("/add")
    @ResponseBody
    public void add(@RequestBody Collect collect) throws IOException {
        iCollectService.add(collect);
        ResponseUtil.showMessage("success", "收藏夹添加成功", "");
    }

    /**
     *
     * @param collect
     * @param flag
     * @throws IOException
     */
    @GetMapping("/getList")
    @ResponseBody
    public void getList(Collect collect, Integer flag) throws IOException {
        ResponseUtil.showMessage("success", "获取全部收藏夹", iCollectService.get(collect, flag));
    }

    /**
     *
     * @param uuid
     * @throws IOException
     */
    @DeleteMapping("/delete")
    @ResponseBody
    public void delete(String uuid) throws IOException {
        iCollectService.delete(uuid);
        ResponseUtil.showMessage("success", "删除收藏成功", null);
    }

    /**
     *
     * @param goodsDbId
     * @throws IOException
     */
    @DeleteMapping("/deleteGoods")
    @ResponseBody
    public void deleteGoods(String goodsDbId) throws IOException {
        iCollectService.deleteGoods(goodsDbId);
        ResponseUtil.showMessage("success", "删除收藏成功", null);
    }

    /**
     *
     * @param csDbId
     * @throws IOException
     */
    @DeleteMapping("/deleteShop")
    @ResponseBody
    public void deleteShop(String csDbId) throws IOException {
        iCollectService.deleteShop(csDbId);
        ResponseUtil.showMessage("success", "删除收藏成功", null);
    }

}
